<div class="layuimini-main">

    <div class="layui-form layuimini-form" lay-filter="updateForm">
        <input type="hidden" name="id" />
        <div class="layui-form-item">
            <label class="layui-form-label required">学生</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" readonly id="studentName" name="studentName" >
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">缺勤时间</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" id="time"name="time" lay-filter="required">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认编辑</button>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['form','axios','layer','jquery','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            axios = layui.axios;

        form.render();

        //日期
        laydate.render({
            elem: '#time'
        });

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;


        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var DISABLED = 'layui-btn-disabled';
            $(':button').addClass(DISABLED);
            $(':button').attr('disabled', 'disabled');
            axios.post('absence/edit',data.field).then(function(response){
              layer.msg(response.message,{
                    icon:6,
                    time: 2000
                },function () {
                    layer.close(parentIndex);
                    layui.table.reload('currentTableId');
                    $(':button').removeClass(DISABLED);
                    $(':button').removeAttr('disabled');
                })
            }).catch(function (error) {
              layer.msg("请求错误",{
                  icon:5,
                  time:2000,
                  anim:6
                },function(){
                  $(':button').removeClass(DISABLED);
                  $(':button').removeAttr('disabled');
                });
            });
            return false;
        });
    });
</script>